package com.ht.module.info.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.ht.module.bus.entity.BusDict;
import com.ht.module.bus.entity.BusFile;
import com.ht.module.vo.MaterialNumVo;
import com.ht.module.vo.NumberRangeVo;
import com.ht.module.vo.SortVo;
import lombok.Data;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;


/**
 * <p>
 * 商品表
 * </p>
 *
 * @author Auto-generator
 * @since 2021-12-03
 */

@TableName("info_goods")
@Data
@Accessors(chain = true)
public class InfoGoods extends Model<InfoGoods> {

    private static final long serialVersionUID = 1L;

    /**
     * 商品主键
     */
    @TableId
    private String id;
    /**
     * 商品名称
     */
    @NotEmpty
    private String name;
    /**
     * 花语
     */
    private String says;
    /**
     * 售价
     */
    @NotNull
    private BigDecimal price;

    /**
     * 用途
     */
    @NotNull
    @TableField(value = "`use`")
    private String use;

    /**
     * 商品预览
     */
    private String text;
    /**
     * 配送说明
     */
    private String distributionNote;
    /**
     * 包装
     */
    private String packaging;
    /**
     * 类别-关联码表-goods_category
     */
    @NotEmpty
    private String category;
    /**
     * 创建时间
     */
    private LocalDateTime createDate;
    /**
     * 创建人
     */
    private String createUser;
    /**
     * 修改时间
     */
    private LocalDateTime updateDate;
    /**
     * 修改人
     */
    private String updateUser;
    /**
     * 逻辑删除
     */
    @TableLogic
    private Integer delFlag;
    /**
     * 商品状态-关联码表：goods_state
     */
    @NotEmpty
    private String state;

    /**
     * 商户id
     */
    private String merchantsId;

    /**
     * 材料集合
     */
    @TableField(exist = false)
    @NotEmpty
    private List<MaterialNumVo> materialList;


    /**
     * 材料字符串
     */
    @TableField(exist = false)
    private String materialStr;

    /**
     * 数量区间
     */
    @TableField(exist = false)
    private NumberRangeVo numberVo;

    /**
     * 价格区间
     */
    @TableField(exist = false)
    private NumberRangeVo priceVo;

    /**
     * 材料
     */
    @TableField(exist = false)
    private String materia;
    /**
     * 区划
     */
    @TableField(exist = false)
    private String inCity;


    /**
     * 排序
     */
    @TableField(exist = false)
    private SortVo sort;


    /**
     * 销量
     */
    @TableField(exist = false)
    private Integer sales;

    /**
     * 展示图片
     */
    @TableField(exist = false)
    private String homeImg;

    /**
     * 材料
     */
    @TableField(exist = false)
    private List<BusFile> busFiles;

    /**
     * 字典
     */
    @TableField(exist = false)
    private List<BusDict> busDicts;


    /**
     * 店铺信息
     */
    @TableField(exist = false)
    private InfoMerchants infoMerchants;



    public void setPriceVo(String priceVo) {
        this.priceVo = JSON.parseObject(priceVo,NumberRangeVo.class);
    }

    public void setNumberVo(String numberVo) {
        this.numberVo = JSON.parseObject(numberVo,NumberRangeVo.class);;
    }
    public void setSort(String sort) {
        this.sort = JSON.parseObject(sort,SortVo.class);;
    }
}
